﻿@model Proggy.Data.Entities.PublishableNode
@{
    ViewBag.Title = "Create new content";

    // get allowed list
    var allowedViewModelTypes = (IEnumerable<SelectListItem>)ViewBag.AllowedViewModelTypes;

    // add js
    Html.AddToBackEndContent("~/Areas/Proggy/Content/Scripts/Proggy.ContentEdit.js", BackEndContentType.JavaScript);

    // check
    if (allowedViewModelTypes.Count() == 0)
    {

    <h2>
        No further content can be created here!</h2>
    <div class="proggy-div">
        <p>
            This could be because you are not allowed to create content here - or no "content
            models" are currently available for this site.</p>
        <p>
            @Html.ActionLink("Click here to return...", "Index", new { selected = Request["ParentNodeId"] })
        </p>
    </div>
    }
    else
    {
    <h2>@ViewBag.Title</h2>
        using (Html.BeginForm())
        {   
    <div class="proggy-form-div">
        @Html.ValidationSummary(false)
        <p>
            @Html.LabelFor(m => m.Name)
            @Html.TextBoxFor(m => m.Name, new { @class = "proggy-textbox proggy-textbox-wide" })
        </p>
        @if (string.IsNullOrEmpty(Request["ParentNodeId"]))
        {
            
            @Html.HiddenFor(m => m.UrlPortion, new { value = Proggy.Data.ProggyDataConstants.TEMP_ROOT_URL })
            
        }
        else
        {
            <p>
                @Html.LabelFor(m => m.UrlPortion)
                @Html.TextBoxFor(m => m.UrlPortion, new { @class = "proggy-textbox proggy-textbox-wide", maxlength="50" })
            </p>
        }
        <p>
            @Html.LabelFor(m => m.UniqueAlias)
            @Html.TextBoxFor(m => m.UniqueAlias, new { @class = "proggy-textbox proggy-textbox-wide" })
        </p>
        <p>
            @Html.LabelFor(m => m.TypeAlias)
            @Html.DropDownListFor(m => m.TypeAlias, allowedViewModelTypes)
        </p>
        @* CAN'T HAVE TEMPLATE YET BECAUSE TYPE NOT SELECTED...
        <p>
            @Html.LabelFor(m=>m.Template)
            @Html.DropDownListFor(m=>m.Template, allowedTemplates)
        </p>*@
        <p>
            <label>
                &nbsp;</label>
            <input type="submit" class="proggy-button-go" value="Next" />
            | @Html.ActionLink("Cancel", "Index", new { success = 5, selected = Request["ParentNodeId"] }, new { @class = "proggy-button-stop" })
        </p>
    </div> 
        }
    }
    
    <script type="text/javascript">
        jQuery(function () {
            var editor = new Proggy.ContentEdit();
            editor.CheckForValidationErrors();
            editor.BindUrlSlug();
            editor.BindUppercaseAliasInput();
        });
    </script>
}
